<template>
  <view class="detailc">
    <view class="task_one">
      <view class="task_left_top">
        <view class="task_round">
          <image src="../../../../static/images/common/task.png" mode=""></image>
        </view>
        <view class="name">攻坚任务</view>
      </view>
      <view class="task_content">
        <view class="task_name">
          <view class="task_left">任务名称</view>
          <view class="task_right nameFont">{{ top.name }}</view>
        </view>
        <view class="task_child">
          <view class="task_test">
            <view class="task_left">任务内容</view>
            <view class="task_right childFont">{{ top.rwnr }}</view>
          </view>
          <view class="task_test">
            <view class="task_left">督查单位</view>
            <view class="task_right childFont">{{ top.dcdw }}</view>
          </view>
          <view class="task_test">
            <view class="task_left">派发时间</view>
            <view class="task_right childFont">{{ top.pfsj }}</view>
          </view>
        </view>
      </view>
    </view>
    <!-- <view class="top">
      <view class="top_header">
        <image src="../../../../static/images/DCXT/renwu.png" mode="" />
        <view class="top_header_v">
          <view>{{ top.name }}</view>
          <view :style="getTypeColor(2)">攻坚任务</view></view
        >
      </view>
      <view class="item">
        <view>任务内容</view>
        <view>{{ top.rwnr }}</view>
      </view>
      <view class="item">
        <view>督查单位</view>
        <view>{{ top.dcdw }}</view>
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '0'"
          >待审批</view
        >
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '1'"
          >审批未通过</view
        >
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '2'"
          >正常待完成</view
        >
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '3'"
          >新反馈</view
        >
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '4'"
          >已完成</view
        >
        <view
          class="state"
          :style="getStateColor(top.state)"
          v-show="top.state === '9'"
          >待立项</view
        >
      </view>
      <view class="item">
        <view>派发时间</view>
        <view>{{ top.pfsj }}</view>
      </view>
    </view> -->
    <view class="info" v-for="(item, index) in info" :key="index">
      <view class="info_item info_item_header">
        <view>子事项</view>
        <view>{{ item.zsx }}</view>
      </view>
      <view class="info_item">
        <view>单位名称</view>
        <view>{{ item.xbdw }}</view></view
      >
      <view class="info_item">
        <view>任务轮次</view>
        <view>{{ item.rwlc }}</view>
      </view>
      <view class="info_item">
        <view>任务时限</view>
        <view>{{ item.rwsx }}</view>
      </view>
      <!-- <view class="info_download item2">
        <view>下载附件</view>
        <view v-for="(item, index) in item.xzfj" :key="index">{{ item }}</view>
      </view> -->
      <view class="banli" @tap="openBlfk(item.zsx, index)">查看详情</view>
    </view>
  </view>
</template>

<script>
import { getSubtasklist } from "../../../../request/dcxt";
export default {
  data() {
    return {
      top: {},
      info: [],
    };
  },
  onReady() {},
  onLoad(option) {
    this.top = JSON.parse(option.info);
    this.getData(option.id);
  },
  methods: {
    getTypeColor(type) {
      if (type == "1") {
        return "backgroundColor:rgba(250, 173, 51, 0.1);color:rgba(250, 173, 51, 1);";
      }
      if (type == "2") {
        return "backgroundColor:rgba(48, 116, 255, 0.1);color:rgba(48, 116, 255, 1);";
      }
    },
    getStateColor(state) {
      if (state == "0" || state == "1" || state == "2") {
        return "backgroundColor:rgba(248, 95, 120, 1);color:#fff;";
      }
      if (state == "3" || state == "4" || state == "9") {
        return "backgroundColor:rgba(250, 173, 51, 1);color:#fff;";
      }
    },
    openBlfk(zsx, index) {
      // uni.navigateTo({
      //   url:
      //     "/pages/dcxt/gjrwgl/blfk/index?name=" +
      //     this.name +
      //     "&type=" +
      //     this.type +
      //     "&zsx=" +
      //     zsx,
      // });
      var _this = this;
      console.log(_this.info[index]);
      uni.navigateTo({
        url: "/pages/dcxt/task/index?info=" + JSON.stringify(_this.info[index]),
      });
    },
    getData(id) {
      var params = {
        loginerId: uni.getStorageSync("loginId"),
        taskMainId: id,
      };
      getSubtasklist(params).then((res) => {
        console.log(res);
        var result = res.data.data;
        var arr = [];
        for (let i = 0; i < result.length; i++) {
          // name:result[i].taskSubName  rwmc  zsx  zt  ztType  xbdw  rwlc  rwsx
          arr.push({
            zsxnr: result[i].taskSubName
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            xbdw:
              result[i].deptName +
              "_" +
              (result[i].unitType == 1 ? "牵头" : "协办"),
            sysId: result[i].sysId,
            type: result[i].type,
            rwlc: result[i].timeRound,
            rwsx: result[i].timeLimit,
            zt: result[i].state,
            ztType: result[i].state,
            name: result[i].taskMainName
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            zsx: result[i].taskSubName
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            rwmc: result[i].taskSubName
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            taskUnitId: result[i].sysId,
            taskSubId: result[i].taskSubId,
            createUser: result[i].createUser,
          });
        }
        this.info = JSON.parse(JSON.stringify(arr));
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.detailc {
  padding-top: 24rpx;

  .task_one {
    background-color: rgba(255, 255, 255, 1);
    padding: 24rpx;
    position: relative;
    margin-bottom: 40rpx;
    box-shadow: 0px 0px 24rpx 0px rgba(48, 116, 255, 0.1);
    border-radius: 24rpx 8rpx 8rpx 8rpx;

    .task_left_top {
      position: absolute;
      top: 0;
      left: 0;
      min-width: 200rpx;
      height: 48rpx;
      background: rgba(48, 116, 255, 0.2);
      border-radius: 24rpx;
      display: flex;
      align-items: center;

      .name {
        font-size: 20rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #3074ff;
        padding: 0 20rpx;
      }

      .task_round {
        width: 48rpx;
        height: 48rpx;
        background: #3074ff;
        z-index: 5;
        box-shadow: 2px 3px 12px 0px rgba(48, 116, 255, 0.4);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;

        image {
          width: 24rpx;
          height: 24rpx;
        }
      }
    }

    .task_content {
      width: 100%;
      margin-top: 40rpx;

      .task_btnArr {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        margin-top: 40rpx;
      }

      .task_btn {
        background: #3074ff;
        border-radius: 4rpx;
        padding: 8rpx 16rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 20rpx;

        image {
          width: 24rpx;
          height: 24rpx;
          margin-right: 10rpx;
        }

        .more {
          width: 24rpx;
          height: 6rpx;
          margin-right: 10rpx;
        }

        .font {
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
        }
      }

      .btn_color1 {
        // background-color: rgba(231, 233, 240, 1);
        background-color: #5cb85c;
      }

      .btn_color2 {
        background-color: rgba(248, 95, 120, 1);
      }
      .btn_color3 {
        background-color: #5cb85c;
      }

      .task_name {
        display: flex;
        padding-bottom: 40rpx;
      }

      .task_child2 {
        padding: 20rpx 0;
      }
      .task_child {
        padding: 20rpx 0;
        border-top: 1rpx solid rgba(231, 233, 240, 1);
        border-bottom: 1rpx solid rgba(231, 233, 240, 1);
      }

      .task_test {
        display: flex;
        margin: 20rpx 0;
      }

      .task_left {
        flex: 2;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }

      .nameFont {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #272b32;
      }

      .task_right {
        flex: 7;
        display: flex;
        align-items: center;
        word-break: break-all;

        .childFont {
          font-size: 28rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: #272b32;
          word-break: break-all;
        }

        .zt_type1 {
          margin-left: 10rpx;
          background: #f85f78;
          border-radius: 4rpx;
          font-size: 20rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
          padding: 0 16rpx;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        .zt_type2 {
          margin-left: 10rpx;
          background: rgba(250, 173, 51, 1);
          border-radius: 4rpx;
          font-size: 20rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
          padding: 0 16rpx;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }
  }
  .top {
    width: 710rpx;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
    border-radius: 8rpx;
    margin: 0 auto;
    margin-bottom: 40rpx;
    padding: 40rpx 24rpx;
    .top_header {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      border-bottom: 1rpx solid rgba(231, 233, 240, 1);
      padding-bottom: 20rpx;
      image {
        width: 40rpx;
        height: 40rpx;
        margin-right: 20rpx;
      }
      .top_header_v {
        flex: 1;
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
        view:nth-child(1) {
          font-size: 32rpx;
          font-family: PingFang SC;
          font-weight: bold;
          color: #272b32;
        }
        view:nth-child(2) {
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 500;
          border-radius: 4rpx;
          padding: 8rpx 16rpx;
        }
      }
    }
    .item {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      margin-top: 18rpx;
      position: relative;
      padding-bottom: 20rpx;
      //   border-bottom: 1rpx solid rgba(231, 233, 240, 1);
      view:nth-child(1) {
        width: 140rpx;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }
      view:nth-child(2) {
        flex: 1;
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #272b32;
      }
      .state {
        display: inline-block;
        font-size: 20rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #ffffff;
        border-radius: 4rpx;
        padding: 8rpx 16rpx;
        position: absolute;
        right: 20rpx;
        top: 50%;
        transform: translateY(-50%);
      }
    }
    .item2 {
      border-bottom: 1rpx solid rgba(231, 233, 240, 1);
    }
  }

  .info {
    width: 710rpx;
    margin: 0 auto;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
    border-radius: 8rpx;
    padding: 0 24rpx;
    margin-top: 50rpx;

    .info_item {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      padding: 16rpx 0;

      view:nth-child(1) {
        width: 150rpx;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }
      view:nth-child(2) {
        flex: 1;
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #272b32;
        margin-left: 20rpx;
      }
    }
    .info_download {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      padding: 16rpx 0;
      view {
        width: 150rpx;
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #3074ff;
      }
      view:nth-child(1) {
        width: 150rpx;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }
    }
    .info_item_header {
      font-size: 28rpx;
      font-family: PingFang SC;
      font-weight: bold;
      color: #272b32;
      border-bottom: 1rpx solid rgba(231, 233, 240, 1);
      padding: 10rpx 0;

      view:nth-child(2) {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #272b32;
      }
    }
    .item2 {
      border-bottom: 1rpx solid rgba(231, 233, 240, 1);
    }
    .banli {
      width: 160rpx;
      height: 50rpx;
      line-height: 50rpx;
      font-size: 28rpx;
      font-family: PingFang SC;
      font-weight: bold;
      color: #649af7;
      text-align: center;
      margin-left: 520rpx;
    }
  }
}
</style>
